package com.xqboss.apps.vo.hama;

import com.xqboss.apps.enums.hama.HamaHelpJoinTypeEnum;
import com.xqboss.apps.enums.hama.HamaHelpUnitEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.math.BigDecimal;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class HamaHelpVO {


    @ApiModelProperty(value = "助力速度（1小时多少力豆）")
    private BigDecimal basicSpeed= BigDecimal.ZERO;

    @Setter
    @ApiModelProperty(value = "助力人数")
    private int manNumber;

    @Setter
    @ApiModelProperty(value = "上级邀请人昵称")
    private String parentUserNick;

    @Setter
    @ApiModelProperty(value = "总共助力空投力豆数量")
    private BigDecimal eggLayingNum=BigDecimal.ZERO;

    @Setter
    @ApiModelProperty(value = "1加入队伍 2未加入队伍")
    private HamaHelpUnitEnum isUnit = HamaHelpUnitEnum.NO;

    @Setter
    @ApiModelProperty(value = "1创建过队伍 2未创建队伍")
    private HamaHelpJoinTypeEnum type;

    @ApiModelProperty(value = "直推累计空投")
    private BigDecimal directAirdropTotal=BigDecimal.ZERO;

    @Setter
    @ApiModelProperty(value = "直推人数")
    private int directNumber=0;

    @ApiModelProperty(value = "间推累计空投")
    private BigDecimal indirectAirdropTotal=BigDecimal.ZERO;

    @Setter
    @ApiModelProperty(value = "间推人数")
    private int indirectNumber=0;

    /**
     * 设置助力速率（直推助力总和 + （间推助力总和 * 间推系数））
     *
     * @param basicSpeed 直推助力总和
     * @param basicSpeedIndirect 间推助力总和
     * @param factor 间推系数
     */
    public void setBasicSpeed(BigDecimal basicSpeed, BigDecimal basicSpeedIndirect, BigDecimal factor) {
        basicSpeed= basicSpeed ==null?BigDecimal.ZERO:basicSpeed;
        basicSpeedIndirect= basicSpeedIndirect ==null?BigDecimal.ZERO:basicSpeedIndirect;
        factor= factor ==null?BigDecimal.ZERO:factor;
        basicSpeed = basicSpeed.add(basicSpeedIndirect.multiply(factor));
        this.basicSpeed = basicSpeed;
    }

    public void setDirectAirdropTotal(BigDecimal directAirdropTotal) {
        directAirdropTotal= directAirdropTotal ==null?BigDecimal.ZERO:directAirdropTotal;
        this.directAirdropTotal = directAirdropTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

    public void setIndirectAirdropTotal(BigDecimal indirectAirdropTotal) {
        indirectAirdropTotal= indirectAirdropTotal ==null?BigDecimal.ZERO:indirectAirdropTotal;
        this.indirectAirdropTotal = indirectAirdropTotal.setScale(2, BigDecimal.ROUND_HALF_UP);
    }

}
